package com.baizhi.extendx;

public class ExtendxDemo2 {
    public static void main(String[] args) {
        //医生对象
        Doctor d = new Doctor();
       // d.name = "魏弘毅"; //编译错误，不能直接访问父类私有的属性
        d.setName("魏弘毅");
        d.rank = "主任医师";

        d.eat();
        d.sleeep();
        d.operation();
        System.out.println("-----------------------");

        //教师对象
        Teacher t = new Teacher();
        //t.name = "李老师";
        t.setName("李老师");
        t.salary = 6000;
        t.eat();
        t.teach();

        System.out.println("--------------------");

        //学生对象
        Student s = new Student();
        s.setName("张三同学");
       // s.name = "张三同学";
        s.sleeep();
        s.study();
    }
}


/**
 * 人类 父类
 */
class Person{
    //成员变量
    private String name;
    int age;
    String address;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //成员方法
    /**
     * 功能：吃放
     */
    public void eat(){
        System.out.println(name+"在吃饭");
    }

    /**
     * 功能：睡觉
     */
    public void sleeep(){
        System.out.println(name+"在睡觉");
    }
}

/**
 * 教师类
 */
class Teacher extends Person{
    //工资
    double salary;

    public void teach(){
        System.out.println("老师在讲课");
    }
}

/**
 * 学生类
 */
class Student extends Person{
    String stuId; //学号

    public void study(){
        System.out.println("学生在学习");
    }
}

/**
 * 医生类
 */
class Doctor extends Person{
    String rank; //级别

    public void operation(){
        System.out.println("医生在做手术");
    }
}